#!/usr/bin/perl

do '../web-lib.pl';
&init_config();

#return @md, ()
sub get_md()
{
	my ($mdlist, @md, $i);
	
	$mdlist = $config{'md_list'};
	@md = split(/\s+/, $mdlist);
	@md = sort {$text{'md_'.$a} cmp $text{'md_'.$b}} @md;
	return @md;
}

sub save_dftcfgtab()
{
	my ($ptrmd, $i, %priority, %m, @pmd);

	$ptrmd = @_[0];

	@pmd = split(/\s+/, $config{'md_list'});

	#pmd is a priorited array, the first module config is first exec to default

	for($i = 0; $i < @$ptrmd; $i++)
	{
		$priority{$ptrmd->[$i]} = $ptrmd->[$i];
	}	

	open(DFTCFGTAB, ">$config{'dfttab'}");

	for($i = 0; $i < @pmd; $i++)
	{
		if($priority{$pmd[$i]})
		{
			print DFTCFGTAB "$pmd[$i]:$config{$pmd[$i]}\n";
		}
	}

	close(DFTCFGTAB);
}

sub exec_dftcfgtab()
{
	my (@dfttab, @line, $i, $rqrb);

	$rqrb = 0;

	open(DFTTAB, $config{'dfttab'});
	@dfttab = <DFTTAB>;
	close(DFTTAB);

	for($i = 0 ; $i < @dfttab; $i++)
	{
		$dfttab[$i] =~ s/#.*$//;
		chomp($dfttab[$i]);
		if($dfttab[$i])
		{
			@line = split(":", $dfttab[$i]);
			if($line[1] == 0)
			{
				my $out = &ez_system12($line[2]);
			}
			$rqrb = $rqrb + $line[1];
		}
	}

	return $rqrb;
}

1;
